package com.syg.servlet02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 缓存
 */
@WebServlet("/expires")
public class _02_ServletExpires extends HttpServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String strData = "我向你传输出了缓存";
        resp.setDateHeader("expires",System.currentTimeMillis()+24*3600*1000);
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println(strData);
    }
}
